package com.ydm.myapp001.dialog;

/**
 * Author: liuzhicheng
 * Time: 18-8-23  下午5:06
 */
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.ydm.myapp001.R;


public class SureTipDialog extends Dialog implements View.OnClickListener {
    private TextView tvDialogTitle;
    private TextView tvDialogMsg;
    private TextView tvCancel;
    private TextView tvConfirm;
    private View btnSperator;

    //
    private String dialogTitle;
    private String dialogMsg;
    private boolean needChoose;
    private String cancelBtnText = "取消";
    private String sureBtnText = "确定";
    private SureTipDialogActionCallBack actionCallBack;

    public SureTipDialog(@NonNull Context var1, String title, String msg, boolean needChoose, SureTipDialogActionCallBack actionCallBack) {
        super(var1, R.style.DialogStyle);
        this.dialogTitle = title;
        this.dialogMsg = msg;
        this.needChoose = needChoose;
        this.actionCallBack = actionCallBack;
    }


    public SureTipDialog(@NonNull Context var1, int var2) {
        super(var1, var2);
    }

    private void initAction() {
        this.tvCancel.setOnClickListener(this);
        this.tvConfirm.setOnClickListener(this);
    }

    private void initView() {
        tvDialogTitle = (TextView) findViewById(R.id.tv_dialog_title);
        tvDialogMsg = (TextView) findViewById(R.id.tv_dialog_msg);
        this.tvCancel = (TextView) this.findViewById(R.id.tv_cancel);
        this.tvConfirm = (TextView) this.findViewById(R.id.tv_confirm);
        btnSperator = (View) findViewById(R.id.v_btn_sperator);


        //
        tvDialogTitle.setText(dialogTitle);
        tvDialogMsg.setText(dialogMsg);
        tvCancel.setText(cancelBtnText);
        tvConfirm.setText(sureBtnText);
        if (needChoose) {
            btnSperator.setVisibility(View.VISIBLE);
            tvCancel.setVisibility(View.VISIBLE);
        }
        else {
            btnSperator.setVisibility(View.GONE);
            tvCancel.setVisibility(View.GONE);
        }
    }


    protected void onCreate(Bundle var1) {
        super.onCreate(var1);
        this.setContentView(R.layout.dialog_sure_tip);
        this.setCancelable(false);
        this.initView();
        this.initAction();
    }


    public void show() {
        super.show();
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_cancel:
                if (actionCallBack != null) {
                    actionCallBack.cancel();
                }
                this.dismiss();
                break;
            case R.id.tv_confirm:
                if (actionCallBack != null) {
                    actionCallBack.sure();
                }
                this.dismiss();
                break;
        }
    }

    /*
     * 定义一个取消订单结果回调接口
     * */
    public interface SureTipDialogActionCallBack {
        public void cancel();
        public void sure();
    }
}
